package io.elegant

import android.content.Context
import android.os.*
@Suppress("DEPRECATION")
fun Context.vibrate(millis: Long, amplitude: Int) = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
    getSystemService(Context.VIBRATOR_SERVICE)
        ?.let { it as Vibrator }
        ?.takeIf { it.hasVibrator() }
        ?.vibrate(VibrationEffect.createOneShot(millis, amplitude))
else TODO("VERSION.SDK_INT < O")
